﻿package mortal.game.view.tianDiRank.item
{
    import Message.Public.*;
    import flash.events.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.tianDiRank.data.*;
    import mortal.mvc.core.*;

    public class TianDiRankHintIcon extends HintBaseIcon
    {
        private var _index:int = 0;
        private var _info:SPlacardDetailInfo;
        private static var _instance:TianDiRankHintIcon;

        public function TianDiRankHintIcon(param1:String)
        {
            super(param1);
            return;
        }// end function

        public function reSetIcon(param1:int) : void
        {
            if (this._index == param1)
            {
                return;
            }
            this._index = param1;
            if (_icon)
            {
                _icon.dispose();
            }
            if (this._index == 0)
            {
                _icon = UIFactory.gBitmap(ImagesConst.TianDiRankDi, 0, 0, this);
            }
            else
            {
                _icon = UIFactory.gBitmap(ImagesConst.TianDiRankTian, 0, 0, this);
            }
            return;
        }// end function

        override protected function clickHandler(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.TianDiRankShowReplaceAlert));
            return;
        }// end function

        public function set info(param1:SPlacardDetailInfo) : void
        {
            var _loc_2:Object = null;
            var _loc_3:int = 0;
            var _loc_4:Array = null;
            this._info = param1;
            if (param1)
            {
                _loc_2 = TianDiRankConfig.instance.getCopyById(this._info.placardConfigId);
                _loc_3 = TianDiRankConfig.instance.getPosById(this._info.placardConfigId);
                _loc_4 = [];
                if (_loc_2 == null)
                {
                    Cache.instance.tianDi.openIndex = null;
                    return;
                }
                if (_loc_2.placardType == 2)
                {
                    _loc_4[0] = 0;
                }
                else
                {
                    _loc_4[0] = 1;
                }
                _loc_4[1] = _loc_3;
                Cache.instance.tianDi.openIndex = _loc_4;
            }
            else
            {
                Cache.instance.tianDi.openIndex = null;
            }
            return;
        }// end function

        public static function get instance() : TianDiRankHintIcon
        {
            if (!_instance)
            {
                _instance = new TianDiRankHintIcon(ImagesConst.TianDiRankDi);
            }
            return _instance;
        }// end function

    }
}
